$(document).ready(function(){
    // getSubs()
    $('.nav_content_item').click(function() {
        $('.nav_content_item').find('span').removeClass('nav_span_select').removeClass('nav_span_unselect');
        $(this).find('span').addClass('nav_span_select');
        $('.nav_content_item').not(this).find('span').addClass('nav_span_unselect');
        let index = $(this).data("index");
        switch (index){
            case 0:
                var url = "index.html";
                window.open(url, '_blank');
                break;
            case 1:
                var url = "html/survey.html";
                window.open(url, '_blank');
                break;
            case 2:
                var url = "html/brand.html";
                window.open(url, '_blank');
                break;
            case 3:
                var url = "html/knowledge.html";
                window.open(url, '_blank');
                break;
            case 4:
                var url = "html/forum.html";
                window.open(url, '_blank');
                break;
        }

    });
    $('.menu_box_item').click(function () {
        $('.menu_box_item').removeClass('menu_box_item_select');
        $(this).addClass('menu_box_item_select');
        $('.menu_box_item').not(this).removeClass('menu_box_item_select');
    });
    $('.unfold_all').click(function () {
        $('.menu_box_item').removeClass('menu_box_item_select');
        $('.menu_box_item').addClass('menu_box_item_select');
    })
});
function getSubs() {
    var loadIndex = layer.load(2);
    let datas = {
        url: '/api/brand_category/subs',
        http_type: 'POST',
        datas: {
            'parent_id':'10'
        }
    }
    wxx.HttpReqeust(datas, function (response) {
        layer.close(loadIndex)
        if (response.code == 1) {
            for (let i = 0; i < response.data.length; i++) {
                let menu_box_item = $("<div class='menu_box_item'></div>")
                let menu_item_out = $("<div class='menu_item_out'></div>")
                let span = $("<span></span>")
                $(span).text(response.data[i].name)
                let img = $("<img src='../icons/icon_arrows_down.png'/>")
                $(menu_item_out).append(span)
                $(menu_item_out).append(img)
                $(menu_box_item).append(menu_item_out)
                $(".menu_box_title").after(menu_box_item)
            }

        } else {
            layer.alert(response.msg, {title: '温馨提示'});
        }
    });
}
